<template>
	<!-- 搜索结果 -->
	<view class="conterScroll">
		<homeFurnishings ref="homeFurnishingsRef" :type="'search'" :title='options.title' :catId='options.catId'/>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow,
		onReachBottom,
		onPullDownRefresh,
		onShareAppMessage,
		onShareTimeline
	} from '@dcloudio/uni-app';
	import {
		ref,
		onMounted
	} from 'vue';
	import homeFurnishings from '@/components/homeFurnishings/index.vue'
	const active = ref(1)
	let options = ref('')
	const homeFurnishingsRef = ref(null)
	onLoad((option) => {
		options.value = option
		homeFurnishingsRef.value.params.title = options.value.title
		homeFurnishingsRef.value.params.catId = options.value.catId
		homeFurnishingsRef.value.params.page = 1
		homeFurnishingsRef.value.queryList();
		// console.log(666,homeFurnishingsRef.value)
		
		// wx.showShareMenu({
		// 	withShareTicket: true,
		// 	menus: ["shareAppMessage", "shareTimeline"]
		// })

	})
    onShow(()=>{
		console.log(options.value)
		
	})
	
	//发送给朋友
	onShareAppMessage((res) => {
		console.log('发送给朋友发送给朋友', res)

		if (casedetail.value) {
			const url = '/pages/home/index?share=1' //你的转发页面路径拼接参数
			console.log('url', url)
			return {
				title: '中鼎智装通',
				type: 0,
				path: url,
				// summary: casedetail.value.desc,
				// imageUrl: casedetail.value.img
			}
		}
	})

	//分享到朋友圈
	onShareTimeline((res) => {
		console.log('分享到朋友圈')
		if (casedetail.value) {
			const url = '/pages/home/index?share=1' //你的转发页面路径拼接参数
			console.log('url', url)
			return {
				title: '中鼎智装通',
				type: 0,
				path: url,
				query: {
					id: id.value,
					// share: '1' // 确保 share=1 存在
				},
				// summary: casedetail.value.desc,
				// imageUrl: casedetail.value.img
			}
		}
	})



	onReachBottom(() => {
		if (homeFurnishingsRef.value.hasMoreData) {
			// console.log('3333触底加载更多数据...');
			homeFurnishingsRef.value.queryList();
		}
	});
	onPullDownRefresh(() => {
		console.log('下拉刷新触发')
		wx.showLoading({
			title: '加载中',
			mask: true, // 是否显示透明蒙层，防止触摸穿透，默认false
			duration: 1000, // 显示时间，单位毫秒，默认1500

		});

		setTimeout(() => {
			homeFurnishingsRef.value.updateHasQuery()
			wx.hideLoading();
			uni.stopPullDownRefresh();
		}, 1000);
	})
</script>


<style lang="less" scoped>
	.conterScroll {
		width: 100%;
		height: calc(100vh- 60rpx);
		// overflow-y: auto;
		background: #f3f3f3;
	}
</style>